const NOT_A_CMD: &str = "Not a cmd!";

pub struct Cmd {
    pub name: String,
    pub params: Vec<String>,
}

impl Cmd {
    pub fn new(cmd: &str) -> Result<Self, &'static str> {
        if !cmd.starts_with("/") {
            return Err(NOT_A_CMD)
        }

        let mut tmp = (&cmd[1..]).split(" ");
        let name = if let Some(name) = tmp.next() {
            name.into()
        } else {
            return Err(NOT_A_CMD);
        };

        let params = tmp.map(|s| String::from(s)).collect();

        Ok(Self {
            name,
            params,
        })
    }
}